<?
require("config.php");

$location_status .= " | Edit";

$show_backnav = "menu";

$menuname = array(
	"Info",
	"Enrollment",
);

$menutarget = array(
	"edit",
	"enroll_menu",
);

require($rela_path . "bin/country.php");

$menutype = 2;

if (NULL!=$action){

   $field = array(
	"code",
	"name",
	"date",
	"time",
	"venue",
	"country",
	"contact",
	"status",
	"order_index",
	"presented",
	"people",
	"country2","course_link","trainer_link",
	);


   $content = array(
	$Code,
	$Name,
	"$Year-$Month-$Day",
	$Time,
	$Venue,
	$Country2,
	$Contact,
	$Status,
	$Order_index,
	$Presented,
	$People,
	$Country,$course_link, $trainer_link,
	);

   $exp = "id='$id'";

   myUpdate($table,$field,$content,$exp);

   header("location:" . $rela_path . "share/msg.php?v=70&id=" . urlEncode($parent_id));

   exit();

}


$Query = "select 
	code,
	name,
	course,
	date,
	datedetails,
	time,
	venue,
	country,
	presented,
	currency,
	fee,
	remark,
	contact,
	contact_tel,
	contact_email,
	status,
	publish_date,
	picture1,
	picture2,
	picture3,
	picture4,
	expiring_date,
	currency1,
	currency2,
	currency3,
	currency4,
	currency5,
	fee1,
	fee2,
	fee3,
	fee4,
	fee5,
	description1,
	description2,
	description3,
	description4,
	description5,
	order_index,
	people,
	enrollments, country2, course_link, trainer_link
from $table where id='$id' Limit 1";
$r = myQuery($Query);




	$Code=		$r[0][0];
	$Name=	$r[0][1];
	$Course=	$r[0][2];
	$Date=	$r[0][3];
	$DateDetails=	$r[0][4];
	$Time=	$r[0][5];
	$Venue=	$r[0][6];
	$Country=	$r[0][7];
	$Presented=	$r[0][8];
	$Currency=	$r[0][9];
	$Fee=	$r[0][10];
	$Remark=$r[0][11];
	$Contact=	$r[0][12];
	$ContactTel=	$r[0][13];
	$ContactEmail=	$r[0][14];
	$Status=	$r[0][15];
	$Publish_date=	$r[0][16];

	$Picture1= $r[0][17];
	$Picture2= $r[0][18];
	$Picture3= $r[0][19];
	$Picture4= $r[0][20];
	$Expiring_date = $r[0][21];

	$Currency1= $r[0][22];
	$Currency2= $r[0][23];
	$Currency3= $r[0][24];
	$Currency4= $r[0][25];
	$Currency5= $r[0][26];
	$Fee1= $r[0][27];
	$Fee2= $r[0][28];
	$Fee3= $r[0][29];
	$Fee4= $r[0][30];
	$Fee5= $r[0][31];
	$Description1= $r[0][32];
	$Description2= $r[0][33];
	$Description3= $r[0][34];
	$Description4= $r[0][35];
	$Description5= $r[0][36];
	$Order_index= $r[0][37];
$People = $r[0][38];
$Enrollments = $r[0][39];
$Country2 = $r[0][40];
$course_link=$r[0][41];
$trainer_link=$r[0][42];
require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>


<form name="form1" enctype="multipart/form-data" method="post" action="">
<!--hidden filed-->
<input name="action" type="hidden" value="edit">
<input name="Code" type="hidden" value="<?print($Code)?>">
<input name="old_Name" type="hidden" value="<?print($Name)?>">
<input name="parent_id" type="hidden" value="<?print($parent_id)?>">


  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image" type="image" onclick="Redirect('menu.php?id=<?=$parent_id?>',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image" type="image" src="../../images/bt_save.gif" width="76" height="22"  <?print($active)?>> 
      </td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right">&nbsp; </td>
    </tr>
    <tr> 
      <td><table border="0">


          <tr> 
            <td class="tdheader">Code :</td>
            <td> <?print($Code)?> </td>
          </tr>

          <tr> 
            <td class="tdheader">Order : </td>
            <td><input type="text" class="text" name="Order_index" size="12" value="<?print($Order_index)?>"></td>
          </tr>
          <tr>
            <td class="tdheader">Currently Enrolled: </td>
            <td><?=$Enrollments?></td>
          </tr>
          <tr>
            <td class="tdheader">Acuity Evening: </td>
            <td>
              <input name="Presented" type="text" class="text" id="Presented" value="<?=$Presented?>" size="40">            </td>
          </tr>
          <tr> 
            <td class="tdheader">Description : </td>
            <td><textarea class="text" name="Name" cols="40" rows="8"><?print(eregi_replace("&", "&amp;", $Name))?></textarea></td>
          </tr>
		  <SCRIPT LANGUAGE="JavaScript">
		  <!--
		  form1.type.value='<?print($type)?>';
		  //-->
		  </SCRIPT>
          <tr> 
            <td class="tdheader">Date :</td>
            <td><?print(FFPdate($Date))?></td>
          </tr>
          <tr> 
            <td class="tdheader">Time :</td>
            <td><textarea class="text" name="Time" cols="40" rows="4"><?print($Time)?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Venue : </td>
            <td><textarea class="text" name="Venue" cols="40" rows="4"><?print($Venue)?></textarea></td>
          </tr>
          <tr>
            <td class="tdheader">Country :</td>
            <td><?print(FFPCountry($Country2))?></td>
          </tr>
          <tr> 
            <td class="tdheader">Language :</td>
            <td>
			<select name="Country2" class="select">
			<option value="dansk" <?php if ($Country == "dansk") { echo "Selected"; } ?>>dansk</option>
			<option value="engelsk" <?php if ($Country == "engelsk") { echo "Selected"; } ?>>engelsk</option>
			
			<option value="kantonesisk" <?php if ($Country == "kantonesisk") { echo "Selected"; } ?>>kantonesisk</option>
			<option value="Mandarin" <?php if ($Country == "Mandarin") { echo "Selected"; } ?>>Mandarin</option>
			
		<option value="dansk / engelsk" <?php if ($Country == "dansk / engelsk") { echo "Selected"; } ?>>dansk / engelsk</option>
		<option value="dansk / kantonesisk" <?php if ($Country == "dansk / kantonesisk") { echo "Selected"; } ?>>dansk / kantonesisk</option>
		<option value="dansk / Mandarin" <?php if ($Country == "dansk / Mandarin") { echo "Selected"; } ?>>dansk / Mandarin</option>
		
		<option value="kantonesisk / engelsk" <?php if ($Country == "kantonesisk / engelsk") { echo "Selected"; } ?>>kantonesisk / engelsk</option>
		<option value="engelsk / Mandarin" <?php if ($Country == "engelsk / Mandarin") { echo "Selected"; } ?>>engelsk / Mandarin</option>
		
		<option value="kantonesisk / Mandarin" <?php if ($Country == "kantonesisk / Mandarin") { echo "Selected"; } ?>>kantonesisk / Mandarin</option>
			</select>			</td>
          </tr>
<!--
          <tr> 
            <td class="tdheader">Fee :</td>
            <td> 
              <?

$sourceData = array(
  "HKD",
  "USD",
  "GBP",
  "EURO",
  "DKK"
  );

FFPSelectBox("Currency",$Currency,$sourceData,$sourceLabel);

?>
              <input  class="text" name="Fee" type="text" size="12" value="<?echo $Fee?>"> </td>
          </tr>
-->

          <tr> 
            <td class="tdheader">Presenter:</td>
            <td> 
              <?

$sourceData = array(
  "user 1",
  "user 2",
  "user 3",
  "user 4"
  );

//FFPSelectBox("Contact",$Contact,$sourceData,$sourceLabel);

?>
<input  class="text" name="Contact" type="text" size="40" value="<?echo $Contact?>">            </td>
          </tr>
          <tr>
            <td class="tdheader">Limit: </td>
            <td>
              <input name="People" type="text" class="text" id="People" value="<?=$People?>" size="5" maxlength="5">            </td>
          </tr>












<input name="bk_Picture1" type="hidden" value="<?print($Picture1)?>">
<input name="bk_Picture2" type="hidden" value="<?print($Picture2)?>">
<input name="bk_Picture3" type="hidden" value="<?print($Picture3)?>">




<?for ($i=1;$i<6;$i++){
	
$v1 = "Currency$i";
$v2 = "Fee$i";
$v3 = "Description$i";
	?>
<?}?>



          <tr>
            <td><strong>Acuity Evening  Link: </strong></td>
            <td><input name="course_link" type="text" class="text" id="course_link" value="<?=$course_link?>" size="40" /></td>
          </tr>
          <tr>
            <td><strong>Presenter Link: </strong></td>
            <td><input name="trainer_link" type="text" class="text" id="trainer_link" value="<?=$trainer_link?>" size="40" /></td>
          </tr>
          
          <tr> 
            <td valign="top" class="tdheader">Publish :</td>
            <td> 
			
              <?

$sourceData = array(
  "Yes",
  "No",
  );

$boxName="Status";

FFPCheckBox("Status",$Status,$sourceData,$sourceLabel);

?>            </td> 			  
          </tr>
          <tr>
            <td class="tdheader">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2" class="tdheader">
              <table width="100%"  border="0" cellspacing="0" cellpadding="2">
                <tr align="center" bgcolor="#0000FF">
                  <td><span class="style1">Registered</span></td>
                  <td><span class="style1">Waiting</span></td>
                  <td><span class="style1">Cancelled</span></td>
                  <td><span class="style1">Attended</span></td>
                  <td><span class="style1">Non-attend</span></td>
                </tr>
								
								<?php
								
								function testempty($something) {
									if (empty($something)) return 0;
									else return $something;
								}
								
								$q = "select count(*) from med_aenroll where aid='$id' and status='Registered'";
								$r = myQuery($q);
								$Registered = testempty($r[0][0]);
								
								$q = "select count(*) from med_aenroll where aid='$id' and status='Waiting'";
								$r = myQuery($q);
								$Waiting = testempty($r[0][0]);
								$q = "select count(*) from med_aenroll where aid='$id' and status='Cancelled'";
								$r = myQuery($q);
								$Canceled = testempty($r[0][0]);
								$q = "select count(*) from med_aenroll where aid='$id' and status='Non-attend'";
								$r = myQuery($q); 
								$Nonattend = testempty($r[0][0]);
								$q = "select count(*) from med_aenroll where aid='$id' and status='Attended'";
								$r = myQuery($q);
								$Attended = testempty($r[0][0]);
								
								
								?>
                <tr align="center">
                  <td><?=$Registered?></td>
                  <td><?=$Waiting?></td>
                  <td><?=$Canceled?></td>
                  <td><?=$Nonattend?></td>
                  <td><?=$Attended?></td>
                </tr>
              </table>            </td>
          </tr>


        </table>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image2" type="image" onclick="Redirect('menu.php?id=<?=$parent_id?>',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image2" type="image" src="../../images/bt_save.gif" width="76" height="22" <?print($active)?>> 
      </td>
    </tr>
  </table>
</form>
<?
require($rela_path . "inc/footer.php");
?>

